<template>
  <!-- <PageWrapper title="图片预览示例"> -->
    <!-- <h1>有预览图</h1>
    <ImagePreview :imageList="imgList" />
    <a-divider /> -->
    <!-- <h1>无预览图</h1>
    <a-button @click="openImg" type="primary">点击预览</a-button> -->
  <!-- </PageWrapper> -->
</template>
<script lang="ts" name="online-preview" setup>
import { ref, onMounted } from 'vue';
import { defineComponent } from 'vue';
import { createImgPreview, ImagePreview } from '/@/components/Preview/index';
import { PageWrapper } from '/@/components/Page';
import { ImageProps } from '/@/components/Preview/src/typing';


import { useMessage } from '/@/hooks/web/useMessage';
import { useRoute, useRouter } from "vue-router"


const imgList = ref<ImageProps[]>([
  { src: 'https://jeecgos.oss-cn-beijing.aliyuncs.com/upload/test/login_1658829954004.png', width: 300 },
  { src: 'https://jeecgos.oss-cn-beijing.aliyuncs.com/upload/test/home_index_1658830084684.png', width: 300 },
  { src: 'https://jeecgos.oss-cn-beijing.aliyuncs.com/upload/test/design_1658830200539.png', width: 300 },
  { src: 'https://static.jeecg.com/upload/test/13_1592320121058.png', width: 300 },
  { src: 'https://static.jeecg.com/upload/test/16_1592320251436.png', width: 300 },
]);
const router = useRouter()
let tenantId = router.currentRoute.value.query?.tenantId
console.log("currentRoute.params: ", tenantId);

onMounted(() => {
    const onImgLoad = ({ index, url, dom }) => {
      console.log(`第${index + 1}张图片已加载，URL为：${url}`, dom);
    };

    const onImgClose = () => {
      console.log("close");
      router.go(-1)
    }
    // 可以使用createImgPreview返回的 PreviewActions 来控制预览逻辑，实现类似幻灯片、自动旋转之类的骚操作
    let imageList = imgList.value.map<string>((i) => i.src);
    createImgPreview({ imageList: imageList, defaultWidth: 700, rememberState: true, onImgLoad, onImgClose });
})
</script>
